package com.tron.dobest.java.trondesign.strategy;

import java.util.function.Function;

public class StrategyStart {

    private Function<String, String> function;

    StrategyStart(){
        function = s -> "这是一个默认的处理方式，啥也不干："+s;
    }

    public void setFunction(Function function) {
        this.function = function;
    }

    public void print(String str) {
        //================================
        String apply = function.apply(str);
        System.out.println(apply);
    }

    public static void main(String[] args) {
        StrategyStart strategyModel = new StrategyStart();
        strategyModel.print("hello");
        strategyModel.setFunction(s->"运行时修改行为："+s);
        strategyModel.print("hello");
    }


}
